﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using POSPlus.DatabaseOperations;

namespace POSPlus.EZBarTender.SignsPrinting
{
	public partial class BatchSelectionDialog : Form
	{
		private List<ProductBatchesHeader> _headers;
		private DataTable _table;

		public String BatchNo
		{
			get { return _batchGridView.SelectedRows[0].Cells["BatchNo"].Value.ToString(); }
		}

		public BatchSelectionDialog()
		{
			InitializeComponent();
		}

		public BatchSelectionDialog(List<ProductBatchesHeader> headers)
		{
			InitializeComponent();
			_headers = headers;
			_table = new DataTable("Table");
			_table.Columns.Add("BatchNo");
			_table.Columns.Add("Description");
			_table.Columns.Add("EndDate");
			foreach (ProductBatchesHeader header in _headers)
			{
				DataRow row = _table.NewRow();
				row["BatchNo"] = header.BatchNo;
				row["Description"] = header.Description;
				row["EndDate"] = header.EndDate;
				_table.Rows.Add(row);
			}
			_batchGridView.DataSource = _table;

			_batchGridView.ClearSelection();
			if (_batchGridView.Rows.Count > 1)
				_batchGridView.CurrentCell = _batchGridView[0, _batchGridView.Rows.Count - 1];
		}
	}
}
